package com.hewang.helloandroid;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;

import com.hewang.component.LoadDia;

public class Loading extends AppCompatActivity {
    private LoadDia mNaLoadDia;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading);
        sLoading();
        findViewById(R.id.btn_switch_loading).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                hLoading(); // 无法触发隐藏，LoadDia设置点击外部无法隐藏
            }
        });
    }

    public void sLoading() {
        if (mNaLoadDia == null || !mNaLoadDia.isShowing()) {
            mNaLoadDia = new LoadDia(this);
            mNaLoadDia.create();
        }
        if (!mNaLoadDia.isShowing()) {
            mNaLoadDia.show();
        }
    }

    public void hLoading() {
        if (mNaLoadDia == null || mNaLoadDia.isShowing()) {
            mNaLoadDia.dismiss();
        }
    }
}